/*
 * Copyright 2017-2018 Allegro.pl
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { expect } from "chai";
import { Timezone } from "chronoshift";
import pickXAxisTicks from "./pick-x-axis-ticks";

const tz = Timezone.UTC;

describe("pickXAxisTicks", () => {
  describe("Number axis", () => {
    it("should pick even ticks", () => {
      expect(pickXAxisTicks([0, 40], tz)).to.be.deep.equal([0, 10, 20, 30, 40]);
    });

    it("should pick ticks starting from domain start", () => {
      expect(pickXAxisTicks([3, 33], tz)).to.be.deep.equal([3, 13, 23, 33]);
    });

    it("should pick ticks always with domain end", () => {
      expect(pickXAxisTicks([3, 31], tz)).to.be.deep.equal([3, 13, 23, 31]);
    });
  });

  describe("Time axis", () => {

    const january = (n: number) => new Date(`2020-01-${n}Z`);

    it("should pick even ticks", () => {
      expect(pickXAxisTicks([january(1), january(8)], tz)).to.be.deep.equal([
        january(1),
        january(2),
        january(3),
        january(4),
        january(5),
        january(6),
        january(7),
        january(8)
      ]);
    });
  });
});
